<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * 滚动图片
 * @author huangtq
 * @date 2017-8-28
 */
class Collection_Model extends AR_Model {
    
	protected $_tb = 't_collection';
    
    public function __construct() {
    	parent::__construct();
    }
    
    /**
     * 首页滚动图片
     * type 1 首页
     */
    public function get_list_ad($where='',$offset,$limit){
    	if($where) $this->db->where($where,'',false);
    	$this->db->select("c.id as cid,c.create_date as cdate,a.*");
    	$this->db->from("t_collection c");
    	$this->db->join("t_article a", "a.id = c.article_id", "left");
    	$this->db->order_by("c.create_date desc");
    	if($limit>0){
    		$this->db->offset($offset);
    		$this->db->limit($limit);
    	}
    	return $this->db->get ()->result_array ();
    }
    
    
    public function getTotal($where='')
    {
    	if($where) $this->db->where($where,'',false);
    	$this->db->select("c.id as cid,c.create_date as cdate,a.*");
    	$this->db->from("t_collection c");
    	$this->db->join("t_article a", "a.id = c.article_id", "left");
    	return $this->db->count_all_results();
    }
}